#ifndef _VECTOR_H_
#define _VECTOR_H_

#include <math.h>

namespace QuadTreeLib
{
	struct Plane
	{
		float a, b, c, d;
	};

	struct Vector3
	{
		float x, y, z;

		Vector3() {}

		Vector3(float a, float b, float c)
			: x(a), y(b), z(c)
		{}

		Vector3(const float *fV)
		{
			x = fV[0]; y = fV[1]; z = fV[2];
		}

		float length()
		{
			return sqrtf(x*x + y*y + z*z);
		}

		inline Vector3 operator + ( const Vector3& rkVector ) const
        {
            return Vector3(
                x + rkVector.x,
                y + rkVector.y,
                z + rkVector.z);
        }

        inline Vector3 operator - ( const Vector3& rkVector ) const
        {
            return Vector3(
                x - rkVector.x,
                y - rkVector.y,
                z - rkVector.z);
        }

		inline Vector3 operator * ( const float fScalar ) const
        {
            return Vector3(
                x * fScalar,
                y * fScalar,
                z * fScalar);
        }

		inline bool operator == ( const Vector3& rkVector ) const
        {
            return ( x == rkVector.x && y == rkVector.y && z == rkVector.z );
        }

		inline Vector3& operator += ( const Vector3& rkVector )
        {
            x += rkVector.x;
            y += rkVector.y;
            z += rkVector.z;

            return *this;
        }

		inline Vector3& operator -= ( const Vector3& rkVector )
        {
            x -= rkVector.x;
            y -= rkVector.y;
            z -= rkVector.z;

            return *this;
        }

		inline friend Vector3 operator * ( const float fScalar, const Vector3& rkVector )
        {
            return Vector3(
                fScalar * rkVector.x,
                fScalar * rkVector.y,
                fScalar * rkVector.z);
        }

		inline Vector3& operator *= ( const float fScalar )
        {
            x *= fScalar;
            y *= fScalar;
            z *= fScalar;
            return *this;
        }
	};
} // namespace QuadTreeLib
#endif